import { Component, OnInit } from '@angular/core';
import { HeroService } from '../../../services/hero.service';
import { StorageService } from '../../../services/storage.service';
import { NzMessageService,NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-notdealfault',
  templateUrl: './notdealfault.component.html',
  styleUrls: ['./notdealfault.component.css']
})
export class NotdealfaultComponent implements OnInit {

  loading = true;
  btn_loading=false;
  public brandName:string='';
  public codes:string='';
  public datalist:Array<any>=[];
  public brandinfo:string;
  public PageIndex:number=1;
  public PageSize:number=10;
  public PageTotal:number;
  constructor(private heroService: HeroService,
              private message: NzMessageService,
              private modalService: NzModalService,
              private storageService: StorageService) { }

  ngOnInit() {
    this.getDatalist();
  }

  //获取排除类型列表数据
  getDatalist(){
    this.btn_loading=true;
    let url=host+"/main/merchantExcludeTasks/list";
    let model="brandNameVague="+this.brandName+"&codesLike="+this.codes+"&page="+this.PageIndex+"&pageSize="+this.PageSize;
    this.heroService.post(url,model).then(result=>{
      this.btn_loading=false;
      if(result.code==0){
        this.datalist=result.data.pageBean.result;
        this.brandinfo=result.data.brand;
        this.PageIndex=result.data.pageBean.curPage;  
        this.PageTotal=result.data.pageBean.totalRow;
        this.loading=false;
      }else{
        this.modalService.error({
          nzTitle: '提示',
          nzContent: result.msg
        });
      }
    })
  }

  delete(id){
    let url=host+"/main/merchantExcludeTasks/del";
    let model='ids='+id;
    this.heroService.post(url,model).then(result=>{
        if(result.code==0){
          this.message.success('删除成功！');
          this.getDatalist();
        }else{
          this.modalService.error({
            nzTitle: '提示',
            nzContent: result.msg
          });
        }
    })
  }
  //分页
  PageIndexChange(event){
    this.PageIndex=event;
    this.getDatalist();
  }

  //导出Excel
  exportOut() {
    const token = this.storageService.getItem("token");
    window.location.href = host + "/main/merchantExcludeTasks/excelExport?token="+token+"&brandNameVague="+this.brandName+"&codesLike="+this.codes;
  }
}

